package com.shop.loan.model;

import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.*;
import xyz.erupt.annotation.sub_field.sub_edit.AttachmentType;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.InputType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.jpa.model.BaseModel;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.util.Date;

@Getter
@Setter
@Entity
@Table(name = "s_user_auth_log")
@Erupt(
        name = "用户实名认证记录",
        orderBy = "id desc",
        power = @Power(add = false, edit = false, delete = false)
)
public class UserAuthLog extends BaseModel {

    @Column(name = "user_id")
    private Long userId;

    @EruptField(
            views = @View(title = "授权流程id"),
            edit = @Edit(title = "授权流程id", notNull = true)
    )
    private String authFlowId;

    @Lob
    @EruptField(
            views = @View(title = "认证url"),
            edit = @Edit(title = "认证url", notNull = true)
    )
    private String authUrl;

    @EruptField(
            views = @View(title = "认证人脸照片", type = ViewType.IMAGE),
            edit = @Edit(title = "认证人脸照片",
                    type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    private String facePhoto;


    @EruptField(
            views = @View(title = "创建时间"),
            edit = @Edit(title = "创建时间",
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date createTime;

    @EruptField(
            views = @View(title = "成功时间"),
            edit = @Edit(title = "成功时间",
                    readonly = @Readonly,
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date successTime;


    @EruptField(
            views = @View(title = "身份证名称"),
            edit = @Edit(title = "身份证名称", search = @Search(vague = true))
    )
    private String cardName;

    @EruptField(
            views = @View(title = "身份证号码"),
            edit = @Edit(title = "身份证号码", search = @Search(vague = true))
    )
    private String cardNum;

    @EruptField(
            views = @View(title = "身份证正面照片", type = ViewType.IMAGE),
            edit = @Edit(title = "身份证正面照片",
                    type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    private String idCardPicFront;

    @EruptField(
            views = @View(title = "身份证反面照片", type = ViewType.IMAGE),
            edit = @Edit(title = "身份证反面照片",
                    type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType(type = AttachmentType.Type.IMAGE))
    )
    private String idCardPicBack;


    @EruptField(
            views = @View(title = "正面ocr结果"),
            edit = @Edit(title = "正面ocr结果", inputType = @InputType(length = 1024))
    )
    private String ocrInfoByFront;

    @EruptField(
            views = @View(title = "反面ocr结果"),
            edit = @Edit(title = "反面ocr结果", inputType = @InputType(length = 1024))
    )
    private String ocrInfoByBack;

    @EruptField(
            views = @View(title = "身份证地址"),
            edit = @Edit(title = "身份证地址")
    )
    private String idCardAddress;


}
